Search
woogc/ps/synchronize_product/completed - WP Global Cart
17160
documentation-template-default,single,single-documentation,postid-17160,theme-awake,eltd-core-1.1,woocommerce-no-js,awake child-child-ver-1.0.0,awake-ver-1.0,eltd-smooth-scroll,eltd-smooth-page-transitions,eltd-mimic-ajax,eltd-grid-1200,eltd-blog-installed,eltd-default-style,eltd-fade-push-text-top,eltd-header-standard,eltd-sticky-header-on-scroll-down-up,eltd-default-mobile-header,eltd-sticky-up-mobile-header,eltd-menu-item-first-level-bg-color,eltd-dropdown-slide-from-top,eltd-,eltd-fullscreen-search eltd-search-fade,eltd-side-menu-slide-from-right,wpb-js-composer js-comp-ver-6.3.0,vc_responsive
 

woogc/ps/synchronize_product/completed

WP Global Cart / woogc/ps/synchronize_product/completed
Share on FacebookTweet about this on TwitterShare on Google+Share on LinkedInShare on TumblrPin on PinterestEmail this to someonePrint this page

woogc/ps/synchronize_product/completed

Name: woogc/ps/synchronize_product/completed
Type: Filter
Arguments: $child_product_ID, $main_product_ID, $child_product_blog_ID

The filter can be employed to execute additional actions upon the completion of a Product synchronization procedure

The provided code example synchronizes the product author as well. This my be helpful for plugins like the Dokan vendors and certain scenarios.
By default, this attribute remains unchanged during product synchronization to maintain consistency across authors/vendors in different shops.


    add_action( 'woogc/ps/synchronize_product/completed', 'woogc_ps_synchronize_product_completed', 10, 3 );
    function woogc_ps_synchronize_product_completed( $child_product_ID, $main_product_ID, $child_product_blog_ID )
        {
            $product_post   =   get_post( $main_product_ID );
               
            switch_to_blog( $child_product_blog_ID );
                        
            $args   =   array(
                                'ID'            => $child_product_ID,
                                'post_author'   => $product_post->post_author,
                            );
            wp_update_post( $args );
            
            restore_current_blog();
               
        }

The code should be placed inside a php file on wp-content/mu-plugins folder.

0
Would love your thoughts, please comment.x
()
x